const Koa = require("koa");
const app = new Koa();

const Router = require("koa-router");
const router = new Router({
  //添加路由前缀
  prefix: "/api",
});

router.get("/list", (ctx) => {
  ctx.body = {
    msg: "koa get router",
  };
});

router.post("/list", (ctx) => {
  ctx.body = {
    msg: "koa post router",
  };
});

app.use(router.routes());

app.listen(3000, () => {
  console.log("3000 running");
});
